<?php
$cs = Yii::app()->getClientScript();
$cs->registerCoreScript('jquery');
?>
<div class="cent_lef">
    <div class="cent_lef1"> 
        <span class="cent_lef1in">
          <a href="<?php echo $this->createUrl('site/index') ?>" title="home">Home</a> » Change Password
        </span> 
    </div>
    <div class="cent_lef2">
       <form method="post" id="sign-in" action="" onsubmit="return checkForm()">
                <?php
                if (!isset($_GET['f'])):
                    ?>
                    <input type="hidden" name="id" id="id">           
                    <ul class="powerleveling" style="margin: 0 10px;">
                        <li>
                            <?php echo CHtml::label('Old Password *', 'User_Password'); ?>
                            <div>
                                <?php echo CHtml::passwordField('User[oldPass]', '', array('size' => 50, 'rel' => 'required', 'rel-value' => 'Please enter Old Password!', 'autocomplete' => 'off')); ?>
                            </div>
                        </li>
                        <?php
                    endif;
                    ?>
                    <li>
                        <?php echo CHtml::label('Password*', 'User_password'); ?>
                        <div>
                            <?php echo CHtml::passwordField('User[newPass]', '', array('size' => 50, 'rel' => 'required', 'rel-value' => 'Please enter New Password!')); ?>
                        </div>
                    </li>
                    <li>
                        <?php echo CHtml::label('Confirm Password*', 'User_confirm_password'); ?>
                        <div>
                            <?php echo CHtml::passwordField('User[confirm_password]', '', array('size' => 50, 'rel' => 'required', 'rel-value' => 'Please Confirm New Password!')); ?>
                        </div>
                    </li>

                </ul>       
                <ul style="padding: 20px 0px 0px 10px;">                 
                    <?php echo CHtml::submitButton('Save', array('class' => 'iput')); ?>  
                </ul>
            </form>
        <div class="clear"></div>
    </div>
</div>
<script>
    function checkForm(){
        var sub = false;
        $.each($("#sign-in input"), function(n, i){
            switch($(i).attr("rel")){
                case 'required':
                    if($(i).val()==""){
                        alert($(i).attr("rel-value"));
                        $(i).focus();
                        sub = false;
                        return false;
                    }else{
                        sub = true;
                    }
                    break;
            }
            
        });
        if(sub === false){
            return false;
        }
        if($("#User_newPass").val()!==$("#User_confirm_password").val()){
            alert("Confirm New Password error!");
            sub = false;
            return false;
        }
        return sub;
    }
</script>